//
//  UILabel+Extension.swift
//  Weibo
//
//  Created by 李亚乐 on 15/12/7.
//  Copyright © 2015年 李亚乐. All rights reserved.
//

import UIKit

extension UILabel {
    
    /// 构造函数
    ///
    /// - parameter title:       标签内容
    /// - parameter color:       文本颜色
    /// - parameter textSize:    字体大小
    /// - parameter screenInset: 标签距离屏幕的宽度
    ///
    /// - returns:  UILabel 对象
    convenience init(title: String,
        color: UIColor = UIColor.darkGrayColor(),
        textSize: CGFloat = 14,
        screenInset: CGFloat = 0) {
            
            self.init()
        
            text = title
            textColor = color
            font = UIFont.systemFontOfSize(textSize)
            numberOfLines = 0
        
            if screenInset == 0 {
                textAlignment = .Center
            } else {
                preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
                textAlignment = .Left
            }
        sizeToFit()
    }
}
